package org.orr.budgetpro.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.orr.budgetpro.entities.Budget;
import org.orr.budgetpro.entities.ExpenseCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class ExpenseCategoryDAO {
	@Autowired
	private SessionFactory sessionFactory;

	public ExpenseCategory getExpenseCategory(Integer categoryId) {
		return (ExpenseCategory) sessionFactory.getCurrentSession().get(
				ExpenseCategory.class, categoryId);
	}

	public List<ExpenseCategory> getExpenseCategories() {
		return sessionFactory
				.getCurrentSession()
				.createQuery("select c from ExpenseCategory as c order by c.displayName")
				.list();
	}
}
